#include "FPCH.h"

#include "FTextureOpenGL.h"

namespace Font
{

	TextureOpenGL::TextureOpenGL(Library* a_Library, unsigned int a_Width, unsigned int a_Height, const unsigned char* a_Data) : Texture(a_Library, a_Width, a_Height, a_Data)
	{
		glGenTextures(1, &m_Handle);
		glBindTexture(GL_TEXTURE_2D, m_Handle);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
		glTexImage2D(
			GL_TEXTURE_2D, 0, GL_RGBA, 
			m_Width, m_Height, 
			0, 
			GL_RGBA, GL_UNSIGNED_BYTE, a_Data
		);
		glBindTexture(GL_TEXTURE_2D, 0);
	}

	void TextureOpenGL::Bind()
	{
		glBindTexture(GL_TEXTURE_2D, m_Handle);
	}

}; // namespace Font